import { Pipe, PipeTransform } from '@angular/core'
import { NumberUtils } from 'monk-design/utils'

@Pipe({
  name: 'ad_toThousands',
})
export class AdToThousandsPipe implements PipeTransform {
  transform(value: string | number) {
    return NumberUtils.toThousands(value)
  }
}

@Pipe({
  name: 'ad_percent',
})
export class AdPercentPipe implements PipeTransform {
  transform(
    divisor: number,
    dividend: number,
    isAddPercentSign: boolean = true,
    fractionDigits: number = 2
  ) {
    return NumberUtils.percent(divisor, dividend, { isAddPercentSign, fractionDigits })
  }
}

@Pipe({
  name: 'ad_convertToTenThousand',
})
export class AdConvertToTenThousandPipe implements PipeTransform {
  transform(numberInput: number, fractionDigits: number = 2, isToThousands: boolean = true) {
    return NumberUtils.convertToTenThousand(numberInput, { fractionDigits, isToThousands })
  }
}
